home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-20
/
rs0422.zip
/
CONFIGUR
/
USERS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-26
|
11KB
|
401 lines
/*
* Copyright 1988 by the Radio Amateur Telecommunications Society
* and Thomas A. Moulton, W2VY
*
* This software may only be modified, copied, distributed or
* executed for non-profit purposes by individuals operating
* systems in the Amateur Radio Service. Credit to the
* author(s) and to the Radio Amateur Telecommunications Society
* must be made in modules where RATS provided software is used,
* and in any announcements and documentation.
*
* As a non-profit, research and development organization, the
* Radio Amateur Telecommunications Society distributes software
* in both executable and source forms. This policy is in place
* to encourage the development and distribution of OSI-based,
* networking tools. In order to protect the interests of the
* Society and the authors, we have placed some conditions
* of use on the software. Other groups are encouraged
* to place the same or similar guidelines on
* software they produce.
*
* The Radio Amateur Telecommunications Society reserves the right
* to specify and alter the terms under which software provided by
* the Society may be used. This policy is consistent with the
* objective of uniform and consistent "Open Systems Interconnections."
*
* All acceptable Amateur Radio related uses of this software
* will be outlined in the "ROSE Implementer's Guide". Individuals
* or organizations wishing to add to, or modify the provisions of
* the guide to accommodate local or evolutionary requirements
* should document the proposed change(s) and forward them to the
* Society. If accepted, written notification will be provided by
* the Society to the submitting organization or individual(s).
* The Society will then issue a "ROSE Implementer's Guide Change
* Notice". Periodically, the Society will re-issue the "ROSE
* Implementer's Guide" and incorporate the text of the change
* notices. This procedure has been put in to place to ensure
* compatibility between systems and to ensure their "Openness"
* and interoperability.
*
* No part of this software may be used in other packages
* without prior authorization from the author or the Society.
* Software incorporating this module, all or in part, must be
* provided to the Society prior to distribution or use by
* anyone not directly involved in testing of the revised
* environment. Current releases of the combined software must
* be provided to the Society in both source and executable
* forms. Adequate documention to produce an executable module
* from the provided source must also be included.
*
* Non-Amateur Radio non-profit uses may be authorized on a case
* by case basis. Inquiries for such use may be made in writing
* to the Society. Non-commercial uses consistent with the
* general principles of Open Systems Interconnection Reference
* Model will be generally considered with favor.
*
* Commercial licensing of the software is also available based
* on normal commercial terms. Licensing inquiries should be
* directed to the Society. Commercial licensing of the standard
* software will be done in situations which materially benefit
* the Amateur Radio Packet Network. Additional licensing is
* reserved by the individual authors.
*
* The Radio Amateur Telecommunications Society provides this software
* on an "as is" basis. The Society assumes no liability for
* loss incurred through the use of this software. Amateur Radio
* use of this software implies non-commercial and voluntary
* development, deployment and use of this software in a "Amateur",
* non-commercial service. Commercial users are encouraged to
* inspect their copies of the source code. Source code modification
* licenses are available if a combined Object and Source Code
* license was not originally established.
*
* The Society may be contacted by writing or calling at:
*
* The Radio Amateur Telecommunications Society
* 206 North Vivyen Street.
* Bergenfield, New Jersey 07621
*
* Telephone: 201-387-8896
*
*/
#include "data.h"
#include "buffer.h"
#include "iface.h"
#include "timer.h"
#include "ax25.h"
#include "ax25l2.h"
#include "l3struc.h"
#include "x25cause.h"
#include "l3calls.h"
#include "tx.h"
#include "config.h"
#include "upfcn.h"
int NULLFCN(), clr_users(), con_users(), recv_boot();
int send_users(), rst_boot(), unload_ok();
struct upfcn users={
{{0xaa, 0xa6, 0x8a, 0xa4, 0xa6, 0x40}, {0x00}}, /* USERS-0 */
rst_boot, clr_users, con_users, recv_boot,
send_users, NULLFCN, unload_ok,
"USERS - ROSE Switch User List Display, Version 1.4\r"
};
extern struct datastr *l2_user_info, l2_info;
extern struct axcb *links;
extern int L3TRIED[16];
extern unsigned char node_addr[16];
extern struct VCS *pending_calls;
extern unsigned int MEMSIZ, HEAPUSD;
extern char str_work[128];
struct datastr *mkpkt(), *bappstr();
unsigned char *malloc(), *calloc();
void free();
struct datastr *user_in;
struct VCS *user_llcn;
int
con_users(vc)
register struct VCS *vc;
{
vc->next = user_llcn; /* This works even when _llcn is NULL */
user_llcn = vc;
vc=vc->peer;
if (!vc) return;
(*vc->SEND)(vc,info_pkt());
}
int
clr_users(vc,c)
struct VCS *vc;
int c;
{
register struct VCS *vcp;
if (user_llcn == vc) user_llcn = vc->next; /* First item */
else {
vcp = user_llcn;
while (vcp->next && vcp->next != vc) vcp = vcp->next;
if (vcp->next == vc) vcp->next = vc->next;
}
vc->next = NULL;
set_p(vc, P1, 0);
}
int
send_users(vc, pkt)
struct VCS *vc;
struct datastr *pkt;
{
static int i, j;
static unsigned char *mem;
register struct VCS *vcx;
static struct ax25_addr stn;
static struct axcb *axcb;
vc_queue_data(vc,pkt);
while ((user_in = vc->tx_queue)) /* There is stuff waiting */ {
vc->tx_queue = user_in->next;
free_buffer(user_in);
user_in = new_buffer(128);
bappstr(user_in, "\rUser List for ");
call_strx(&L3CALL[0], str_work);
bappstr(user_in, str_work);
bappch(user_in,0x20);
x121_strx(node_addr, str_work);
bappstr(user_in, str_work);
bappstr(user_in,"\rMemory Size is: ");
putdec(user_in, MEMSIZ, 6);
bappstr(user_in," Bytes\rMemory Used is: ");
putdec(user_in, HEAPUSD, 6);
bappstr(user_in," Bytes\rEPROM Checksum: ");
mem = 0;
j = 0;
while ((int)mem >= 0) j += *mem++;
putxch(user_in, j&0x0ff);
bappstr(user_in,"h\r\r");
(*vc->peer->SEND)(vc->peer, user_in);
user_in = new_buffer(1024);
axcb=links;
while (axcb) /* For all links */ {
call_strx(&axcb->path[0], str_work);
bappstr(user_in, str_work);
if (axcb->rpid == PID_X25) {
bappstr(user_in," X.25 Trunk (R");
bappch(user_in,axcb->R+0x30);
if (vcx=axcb->llcn) bappstr(user_in,") with the following connections:\r");
else bappstr(user_in,") with no connections.\r");
while (vcx) {
prt_vc(vcx);
vcx=vcx->next;
}
} else if (axcb->rpid == PID_TNC || axcb->rpid == 0) {
bappstr(user_in," AX25L2 User Linked to ");
if (axcb->llcn) /* Have my VC */ {
if (axcb->llcn->peer) /* Have peer */ {
get_nsap(axcb->llcn->peer, &stn);
call_strx(&stn, str_work);
bappstr(user_in, str_work);
bappstr(user_in," @ ");
x121_strx(axcb->llcn->peer->addr, str_work);
bappstr(user_in, str_work);
} else bappstr(user_in, "*** NO PEER ***");
} else bappstr(user_in, "*** NO VC ***");
bappstr(user_in,"\r");
} else {
bappstr(user_in, "*** Unknown Protocol ID ");
putxch(user_in, axcb->rpid);
bappstr(user_in, " ***\r");
}
axcb=axcb->next;
}
if (vcx=pending_calls) {
bappstr(user_in,"\rPending Calls:\r");
while (vcx) {
prt_vc(vcx);
vcx=vcx->next;
}
} else bappstr(user_in,"\rThere are no calls Pending.\r");
bappstr(user_in,"\rThe Following X.25 Trunks are listed as Out of Order:\r");
j=0;
for (i=1;i<16;i++) /* For all configured links */ {
if (L3TRIED[i] > 0) /* Bad */ {
j=1;
call_strx(&L3CALL[i], str_work);
bappstr(user_in, str_work);
bappstr(user_in, " With ");
put_hms(user_in, L3TRIED[i]);
bappstr(user_in," Hours Left.\r");
}
}
if (!j) bappstr(user_in,"<None> - All Links Operational\r");
(*vc->peer->SEND)(vc->peer, user_in);
user_in = NULL;
}
return 256; /* We are never busy! */
}
/*
User List for N2DSY-3 3100201744
KD6TH-4 AX25L2 User linked to KB1BD-4 @ 3100609443
WB2JQR-3 X.25 Trunk with the following connections:
KB1BD-5 @ 3100609443 P4 D1 > KD6TH-4 @ 3100201744
WB2DRD-3 @ 3100609530 P4 D1 < W2VY @ 3100201478
W2VY-6 X.25 Trunk with the following connections:
W2VY @ 3100201478 P4 D1 > WB2DRD-3 @ 3100609530
KD6TH-6 X.25 Trunk with no connections active.
The Following X.25 Trunks are listed as Out of Order:
N2ELC-3
*/
x121_strx(x121, str)
char x121[];
register char *str;
{
static int l;
int x121_str();
l = x121_str(x121, str);
str += l;
while (l<15) {
*str++ = 0x20;
l++;
}
*str = NULL;
}
call_strx(stn, str)
struct ax25_addr *stn;
register char *str;
{
static int j;
int call_str();
j=call_str(stn, str);
if (str[j-1] == '0' && str[j-2] == '-') j -= 2;
str += j;
while (j<9) {
*str++ = 0x20;
j++;
}
*str = NULL;
}
putdec(bp, val, w)
struct datastr *bp;
unsigned int val;
int w;
{
static char z[10];
static unsigned int v, u10;
static int i;
u10 = 10;
for (i=0;i<10;i++) z[i]=' ';
z[9]=0;
v=val;
for (i=8;i>=0, v!=0;i--) /* Stuff one digit at a time */ {
z[i] = '0' + (v - (v/u10)*u10);
v = v / 10;
}
bappstr(bp, &z[9-w]);
}
#if 0
putdec(bp, val)
struct datastr *bp;
unsigned char val;
{
static char z[4];
static unsigned char v;
z[0]=' ';
z[1]=' ';
z[2]=' ';
z[3]=0;
v=val;
if (v>99) {
z[0] = (v/100) + '0';
v = v - ((z[0]-'0') * 100);
z[1] = (v/10) + '0';
v = v - ((z[1]-'0') * 10);
}
if (v>9) {
z[1] = (v/10) + '0';
v = v - ((z[1]-'0') * 10);
}
z[2] = v + '0';
bappstr(bp, z);
}
#endif
put_hms(bp, val)
struct datastr *bp;
int val;
{
static char z[9];
static int v, i;
for (i=0;i<9;i++) z[i]='0';
z[2]=z[5]=':';
z[8]=0;
v=val;
i = v/3600;
if (i>0) {
z[0] = (i/10) + '0';
z[1] = (i - ((i/10) * 10)) +'0';
}
v = v - (i*3600);
i = v/60;
if (i>0) {
z[3] = (i/10) + '0';
z[4] = (i - ((i/10) * 10)) +'0';
}
v = v - (i*60);
i = v;
if (i>0) {
z[6] = (i/10) + '0';
z[7] = (i - ((i/10) * 10)) +'0';
}
bappstr(bp,z);
}
prt_vc(vcx)
register struct VCS *vcx;
{
static struct ax25_addr stn;
get_nsap(vcx,&stn);
call_strx(&stn, str_work);
bappstr(user_in, str_work);
bappstr(user_in," @ ");
x121_strx(vcx->addr, str_work);
bappstr(user_in, str_work);
bappstr(user_in,"(");
putdec(user_in, vcx->lcn, 3);
bappstr(user_in," P");
bappch(user_in, vcx->P+0x31);
bappstr(user_in," D");
bappch(user_in, vcx->D+0x31);
bappstr(user_in, vcx->alt ? ") <-- " : ") --> ");
if (vcx->peer) {
get_nsap(vcx->peer,&stn);
call_strx(&stn, str_work);
bappstr(user_in, str_work);
bappstr(user_in," @ ");
x121_strx(vcx->peer->addr, str_work);
bappstr(user_in, str_work);
} else bappstr(user_in, "*** NO PEER ***");
bappstr(user_in,"\r");
}